package com.opo5.logisticsmanagement.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.opo5.logisticsmanagement.validationgroup.InsertValida;
import com.opo5.logisticsmanagement.validationgroup.UpdateValida;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * 
 * @TableName tbs_user
 */
@TableName(value ="tbs_user")
@Data
public class User implements Serializable {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    @NotNull(groups = UpdateValida.class,message = "更新不能没有id")
    private Integer id;

    /**
     * 用户名
     */
    @NotBlank(message = "用户名不能为空")
    private String nickname;

    /**
     * 员工姓名
     */
    @NotBlank(message = "员工姓名不能为空")
    private String username;

    /**
     * 密码
     */
    @NotBlank(groups = {InsertValida.class},message = "密码不能为空")
    private String password;

    /**
     * 性别
     */
    @NotNull(message = "性别不能为空")
    @Pattern(regexp = "^[男女]$",message = "用户性别只能是难和女")
    private String gender;

    /**
     * 入职时间
     */
    private Date entrydate;

    /**
     * 离职时间
     */
    private Date resignationdate;

    /**
     * 手机号码
     */
    @Pattern(regexp = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$", message = "手机号格式错误")
    @NotBlank(message = "手机号不能为空")
    private String phonenum;

    /**
     * 状态
     */
    @NotNull(message = "状态不能为空")
    @Pattern(regexp ="^[01]$",message = "只能是0和1")
    private String state;

    /**
     * 部门外键
     */
    @NotNull(message = "部门外键不能为空")
    private Integer deptId;

    /**
     * 角色Id
     */
    @NotNull(groups = UpdateValida.class,message = "角色id不能为空")
    private Integer roleId;

    /**
     * 地址Id
     */
    @NotNull(groups = UpdateValida.class,message = "地址id不能为空")
    private Integer addressId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

}